package br.domsd.pocketcontrol.action;

import java.util.Calendar;

import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.util.Log;
import android.view.View;
import br.domsd.pocketcontrol.MonthExpensesActivity;
import br.domsd.pocketcontrol.R;
import br.domsd.pocketcontrol.model.Period;
import br.domsd.pocketcontrol.utils.Utils;

public class MonthExpensesActivityActionListener implements OnClickListener, android.view.View.OnClickListener
{

	private XMLHandler xmlHandler;
	private MonthExpensesActivity monthExpensesActivity;
	private Period period;
	
	public MonthExpensesActivityActionListener(MonthExpensesActivity paramMonthExpensesActivity)
	{
		monthExpensesActivity = paramMonthExpensesActivity;
		xmlHandler = new XMLHandler(monthExpensesActivity.getApplicationContext());
		
		String stringPeriod = monthExpensesActivity.getIntent().getExtras().getString("openedPeriod");
		
		period = Utils.stringToPeriod(stringPeriod);
		xmlHandler.openXML(period);
		
	}
	
	public void onClick(View v) 
	{
		
		if(v.getId() == R.id.btnLaunch)
		{
			Log.d(MonthExpensesActivityActionListener.class.getSimpleName(), "Button Clicked: Launch Expense");
			Log.d(MonthExpensesActivityActionListener.class.getSimpleName(), "Ammount: " + monthExpensesActivity.getDate());
			Log.d(MonthExpensesActivityActionListener.class.getSimpleName(), "Ammount: " + monthExpensesActivity.getAmmountToLaunch());
			xmlHandler.addExpense(period, monthExpensesActivity.getDate(), monthExpensesActivity.getAmmountToLaunch());
		}
		
	}

	public void onClick(DialogInterface dialog, int which) 
	{
		// TODO Auto-generated method stub
		
	}

}
